<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2025/7/26 星期六
  Time: 19:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <base href="${pageContext.request.contextPath}/" />
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="static/bootstrap-3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="static/bootstrapvalidator/css/bootstrapValidator.css"
          rel="stylesheet">

    <script src="static/jquery/jquery-1.10.2.min.js"></script>
    <script src="static/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script src="static/bootstrapvalidator/js/bootstrapValidator.js"></script>

</head>
<body>


<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">编辑员工信息</h4>
    </div>

    <div class="panel-body">
        <form action="hr/emp/addEmp" id="myform" method="post"
              class="form-horizontal" role="form">
            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="empName" class="col-md-4 control-label">员工名称</label>
                    <div class="col-md-8">
                        <input type="hidden" id="oid" name="oid" value="">
                        <input type="text" id="empName" name="empName"
                               class="form-control" placeholder="请输入员工名称"
                               value="">
                    </div>
                </div>

                <div class="form-group col-md-6">
                    <label for="deptid" class="col-md-4 control-label">所属部门</label>
                    <div class="col-md-8">
                        <select name="deptid" class="form-control" id="deptid">
                            <option value="">--请选择--</option>

                            <c:forEach items="${departments}" var="department">
                                <option value="${department.oid}">${department.deptName}</option>
                            </c:forEach>

                        </select>
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="sex" class="col-md-4 control-label">员工性别</label>
                    <div class="col-md-8" id="sex">
                        <input type="radio" name="sex"  value="M">男
                        &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="sex"  value="F">女
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="jobid" class="col-md-4 control-label">员工职位</label>
                    <div class="col-md-8">
                        <select name="jobid" class="form-control" id="jobid">
                            <option value="">--请选择--</option>

                        </select>
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="phone" class="col-md-4 control-label">员工电话</label>
                    <div class="col-md-8">
                        <input type="text" id="phone" name="phone" class="form-control"
                               placeholder="请输入员工电话" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="email" class="col-md-4 control-label">员工邮箱</label>
                    <div class="col-md-8">
                        <input type="text" id="email" name="email" class="form-control"
                               placeholder="请输入员工邮箱" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="school" class="col-md-4 control-label">毕业学校</label>
                    <div class="col-md-8">
                        <input type="text" id="school" name="school"
                               class="form-control" placeholder="请输入员工毕业学校"
                               value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="degree" class="col-md-4 control-label">员工学历</label>
                    <div class="col-md-8">
                        <select name="degree" class="form-control" id="degree">
                            <option value="">--请选择--</option>

                            <c:forEach items="${degrees}" var="degree">
                                <option value="${degree.oid}">${degree.name}</option>
                            </c:forEach>

                        </select>
                    </div>
                </div>
            </div>


            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="major" class="col-md-4 control-label">所学专业</label>
                    <div class="col-md-8">
                        <input type="text" id="major" name="major"
                               class="form-control" placeholder="请输入员工所学专业"
                               value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="birthday" class="col-md-4 control-label">员工生日</label>
                    <div class="col-md-8">
                        <input type="date" id="birthday" name="birthday"
                               class="form-control" placeholder="请输入员工生日"
                               value="">
                        <input type="hidden" name="state" value="Y">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <hr>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="username" class="col-md-4 control-label">登录账号</label>
                    <div class="col-md-8">
                        <input type="text" id="username" name="username"
                               class="form-control" placeholder="请输入登录账号"
                               value="">
                        <input type="hidden" id="aid" name="aid" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="password" class="col-md-4 control-label">登录密码</label>
                    <div class="col-md-8">
                        <input type="password" id="password" name="password"
                               class="form-control" placeholder="请输入登录密码"
                               value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <hr>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="workDate" class="col-md-4 control-label">参加工作时间</label>
                    <div class="col-md-8">
                        <input type="date" id="workDate" name="workDate"
                               class="form-control" value="">
                        <input type="hidden" id="empid" name="empid" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="joinDate" class="col-md-4 control-label">加入公司时间</label>
                    <div class="col-md-8">
                        <input type="date" id="joinDate" name="joinDate"
                               class="form-control" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="contractStart" class="col-md-4 control-label">合同开始时间</label>
                    <div class="col-md-8">
                        <input type="date" id="contractStart" name="contractStart"
                               class="form-control" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="contractEnd" class="col-md-4 control-label">合同结束时间</label>
                    <div class="col-md-8">
                        <input type="date" id="contractEnd" name="contractEnd"
                               class="form-control" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="fileDate" class="col-md-4 control-label">调入档案时间</label>
                    <div class="col-md-8">
                        <input type="date" id="fileDate" name="fileDate"
                               class="form-control" value="">
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="assureDate" class="col-md-4 control-label">担保签订时间</label>
                    <div class="col-md-8">
                        <input type="date" id="assureDate" name="assureDate"
                               class="form-control" value="">
                    </div>
                </div>
            </div>


            <div class="col-md-12">
                <div class="form-group col-md-6">
                    <label for="secretDate" class="col-md-4 control-label">保密协议签订时间</label>
                    <div class="col-md-8">
                        <input type="date" id="secretDate" name="secretDate"
                               class="form-control" value="">
                    </div>
                </div>
            </div>

            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <hr>
                </div>
            </div>

            <div id="exps">

            </div>

            <div class="col-md-12">
                <div class="form-group col-md-12">
                    <div class="col-md-10  col-md-offset-2">
                        <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
                        <button type="button" id="addExprience" class="btn btn-success">添加工作经历</button>
                        <button type="submit" id="editdeptbtn" class="btn btn-success">提交信息</button>
                        <button type="reset" id="resetbtn" class="btn btn-default">取消操作</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- 工作经历模板 -->
<div id="expdemo" style="display: none;">
    <div>
        <div class="col-md-12">
            <div align="center">
                <label>工作经历</label><BR><BR>
            </div>
        </div>
        <div class="col-md-12">
            <div class="form-group col-md-6">
                <label for="startDate" class="col-md-4 control-label">开始时间</label>
                <div class="col-md-8">
                    <input type="date" id="startDate" name="startDate" class="form-control" placeholder="请输入开始时间">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="endDate" class="col-md-4 control-label">结束时间</label>
                <div class="col-md-8" id="endDate">
                    <input type="date" name="endDate" class="form-control" placeholder="请输入结束时间">
                </div>
            </div>
        </div>

        <div class="col-md-12">
            <div class="form-group col-md-6">
                <label for="companyName" class="col-md-4 control-label">所在公司</label>
                <div class="col-md-8" id="companyName">
                    <input type="text" name="companyName" class="form-control" placeholder="请输入所在公司" value="">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="deptName" class="col-md-4 control-label">所在部门</label>
                <div class="col-md-8" id="deptName">
                    <input type="text" name="deptName" class="form-control" placeholder="请输入所在部门" value="">
                </div>
            </div>
        </div>

        <div class="col-md-12">
            <div class="form-group col-md-6">
                <label for="jobName" class="col-md-4 control-label">所在职位</label>
                <div class="col-md-8" id="jobName">
                    <input type="text" name="jobName" class="form-control" placeholder="请输入所在职位" value="">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="proofer" class="col-md-4 control-label">证明人</label>
                <div class="col-md-8" id="proofer">
                    <input type="text" name="proofer" class="form-control" placeholder="请输入证明人">
                </div>
            </div>
        </div>
        <div class="col-md-12">
            <div class="form-group col-md-6">
                <label for="description" class="col-md-4 control-label">工作描述</label>
                <div class="col-md-8">
						<textarea class="form-control" id="description"
                                  name="description" rows="5" placeholder="请输入工作描述介绍"></textarea>
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="expphone" class="col-md-4 control-label">证明人电话</label>
                <div class="col-md-8" id="expphone">
                    <input type="text" name="expphone" class="form-control" placeholder="请输入证明人电话">
                    <BR>
                    <input type="button" onclick="deteleExp(this)" class="btn btn-danger" value="删除此工作经历">
                </div>
            </div>
        </div>
        <div class="col-md-12">
            <div class="form-group col-md-12">
                <hr>
            </div>
        </div>
    </div>
</div>



<%--<div class="modal fade" id="selectempModal" tabindex="-1" role="dialog" aria-labelledby="selectempModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="selectempModalLabel">选择员工</h4>
            </div>
            <div class="modal-body">
                <form action="" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="dept" class="col-md-4 control-label">所属部门</label>
                        <div class="col-md-5">
                            <select name="dept" class="form-control" id="dept">
                                <option value="">--请选择--</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="job" class="col-md-4 control-label">所属职位</label>
                        <div class="col-md-5">
                            <select name="job" class="form-control" id="job">
                                <option value="">--请选择--</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="emp" class="col-md-4 control-label">员工信息</label>
                        <div class="col-md-5">
                            <select name="emp" class="form-control" id="emp" size="10">
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="sub" class="btn btn-primary">确认选择</button>
            </div>
        </div>
    </div>
</div>--%>

<script>
    $(document).ready(function(){
        $.getJSON("dept/listDeptUseSelect",function(listdept){
            var dept = $("#dept")[0];
            dept.options.length=1;
            for(var i=0;i<listdept.length;i++){
                var d = listdept[i];
                dept.options.add(new Option(d.deptName,d.oid));
            }
        });

        $("#dept").change(function(){
            $("#job")[0].options.length=1;
            $("#emp")[0].options.length=0;
            if(this.value==""){
                return;
            }
            $.getJSON("dept/listDeptJobUseSelect",{deptid:this.value},function(listjob){
                var job = $("#job")[0];
                job.options.length=1;
                for(var i=0;i<listjob.length;i++){
                    var job1 = listjob[i];
                    job.options.add(new Option(job1.name,job1.oid));
                }
            });

            $.getJSON("emp/listEmpUseSelete",{deptid:$("#dept").val()},function(emps){
                var emp = $("#emp")[0];
                emp.options.length=0;
                for(var i=0;i<emps.length;i++){
                    var e = emps[i];
                    emp.options.add(new Option(e.empName,e.oid));
                }
            });
        });

       /* $("#job").change(function(){
            $.getJSON("emp/listEmpUseSelete",{deptid:$("#dept").val(),jobid:this.value},function(emps){
                var emp = $("#emp")[0];
                emp.options.length=0;
                for(var i=0;i<emps.length;i++){
                    var e = emps[i];
                    emp.options.add(new Option(e.empName,e.oid));
                }
            });
        });*/

        $("#sub").click(function(){
            var eid=$("#emp").val();
            if(eid!=null){
                var empName=$("#emp option:selected").text();
                setempvalue(eid,empName);
                $('#selectempModal').modal('hide');
            }else{
                alert("请选择员工");
            }

        });

        $('#selectempModal').on('show.bs.modal',function() {
            $("#dept").val("");
            $("#job")[0].options.length=1;
            $("#emp")[0].options.length=0;
        });
    });
</script>






<script type="text/javascript">
    $(document).ajaxError(function(event,xhr) {
        if(xhr.status=="403"){//没有权限
            document.location.href = xhr.getResponseHeader("url");
        }else if(xhr.status!="200"){
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>

<script type="text/javascript">
    function setempvalue(eid, empName) {
        $("#manager").val(eid);
        $("#managername").val(empName);
    }
</script>
</body>


<script type="text/javascript">
    function deteleExp(o){
        $(o).parent().parent().parent().parent().remove();
    }

    $(document).ready(function() {

        $("#deptid").change(function(){
            $("#jobid")[0].options.length=1;
            if(this.value==""){
                return;
            }
            $.getJSON("hr/zz-department-job/listDeptJobUseSelect",{deptid:$("#deptid").val()},function(listjob){
                var job = $("#jobid")[0];
                job.options.length=1;
                for(var i=0;i<listjob.length;i++){
                    var job1 = listjob[i];
                    job.options.add(new Option(job1.jobName,job1.jobid));
                }
            });
        });

        $("#addExprience").click(function(){
            $("#exps").append($("#expdemo").html());
            $('#myform').bootstrapValidator('addField', 'proofer', {
                validators: {
                    notEmpty : {/*非空提示*/
                        message : '证明人不能为空'
                    },
                    stringLength : {
                        min : 2,
                        max : 10,
                        message : '证明人名称长度需在2-10位'
                    }

                }
            });
            $('#myform').bootstrapValidator('addField', 'expphone', {
                validators: {
                    notEmpty : {/*非空提示*/
                        message : '证明人电话不能为空'
                    },
                    regexp : {
                        regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                        message : '电话格式不正确'
                    }
                }
            });
            $('#myform').bootstrapValidator('addField', 'startDate', {
                validators: {
                    notEmpty : {/*非空提示*/
                        message : '工作开始时间不能为空'
                    },
                    date : {
                        format : 'YYYY-MM-DD',
                        message : '员工生日格式不正确'
                    }
                }
            });
            $('#myform').bootstrapValidator('addField', 'endDate', {
                validators: {
                    notEmpty : {/*非空提示*/
                        message : '工作结束时间不能为空'
                    },
                    date : {
                        format : 'YYYY-MM-DD',
                        message : '员工生日格式不正确'
                    }
                }
            });
        });

        $("#myform").bootstrapValidator({
            message : 'This value is not valid',
            feedbackIcons : {/*input状态样式图片*/
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            fields : {
                empName : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '员工姓名不能为空'

                        },
                        stringLength : {
                            min : 2,
                            max : 10,
                            message : '员工名称长度需在2-10位'
                        }
                    }
                },
                sex : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '请选择员工性别'
                        }
                    }
                },
                phone : {
                    validators : {
                        regexp : {
                            regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                            message : '电话格式不正确'
                        }
                    }
                },
                email : {
                    validators : {
                        emailAddress : {
                            message : 'E-mail格式不正确'
                        }
                    }
                },
                school : {
                    validators : {
                        stringLength : {
                            max : 10,
                            message : '学校名称输入过长'
                        }
                    }
                },
                major : {
                    validators : {
                        stringLength : {
                            max : 20,
                            message : '专业名称输入过长'
                        }
                    }
                },
                birthday : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '员工生日格式不正确'
                        }
                    }
                },
                username : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '登录账号不能为空'
                        },
                        stringLength : {
                            min : 3,
                            max : 20,
                            message : '登录账号长度需在3-20位'
                        },
                        regexp : {
                            regexp : /^[a-zA-Z][a-zA-Z0-9]{2,19}$/,
                            message : '登录账号格式:字母和数字组成,首字母必须是字母'
                        },
                        remote:{
                            url:"hr/zz-account/checkUsername",
                            delay:1000,
                            type:'post',
                            message:'账号已存在!',
                            data:function(validator){
                                return {
                                    'username':$("#username").val(),
                                    'aid':$("#aid").val(),
                                };
                            }
                        }
                    }
                },
                password : {
                    validators : {
                        notEmpty : {/*非空提示*/
                            message : '登录密码不能为空'
                        },
                        stringLength : {
                            min : 6,
                            max : 20,
                            message : '登录密码长度需在6-20位'
                        }
                    }
                },
                workDate : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                joinDate : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                fileDate : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                contractStart : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                contractEnd : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                assureDate : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                secretDate : {
                    validators : {
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '日期格式不正确'
                        }
                    }
                },
                proofer : {
                    validators: {
                        notEmpty : {/*非空提示*/
                            message : '证明人不能为空'
                        },
                        stringLength : {
                            min : 2,
                            max : 10,
                            message : '证明人名称长度需在2-10位'
                        }

                    }
                },
                expphone : {
                    validators: {
                        notEmpty : {/*非空提示*/
                            message : '证明人电话不能为空'
                        },
                        regexp : {
                            regexp : /^(^(\d{3,4}-)?\d{7,8})$|^((1[0-9][0-9]\d{8}$))$/,
                            message : '电话格式不正确'
                        }
                    }
                },
                startDate : {
                    validators: {
                        notEmpty : {/*非空提示*/
                            message : '工作开始时间不能为空'
                        },
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '员工生日格式不正确'
                        }
                    }
                },
                endDate : {
                    validators: {
                        notEmpty : {/*非空提示*/
                            message : '工作结束时间不能为空'
                        },
                        date : {
                            format : 'YYYY-MM-DD',
                            message : '员工生日格式不正确'
                        }
                    }
                }
            },
            submitHandler : function(validator,form, submitButton) {
                validator.defaultSubmit();
            }
        });


        $("#resetbtn").click(function() {
            $("#myform").data("bootstrapValidator").resetForm();
        });
    });


</script>
</html>
